package com.sskj.wallet.ui.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.sskj.common.base.App;
import com.sskj.common.util.TimeFormatUtil;
import com.sskj.lib.Constans;
import com.sskj.lib.RConfig;
import com.sskj.lib.base.BaseActivity;
import com.sskj.wallet.R;
import com.sskj.wallet.R2;
import com.sskj.wallet.bean.ChongtiDetailsBean;
import com.sskj.wallet.presenter.ChongtiDetailsPresenter;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * @author Hey
 * Create at  2019/07/10
 */
@Route(path = RConfig.WALLET_ACTIVITY_DETAILS_CHONGTI)
public class ChongtiDetailsActivity extends BaseActivity<ChongtiDetailsPresenter> {


    @BindView(R2.id.tvTitle)
    TextView tvTitle;
    @BindView(R2.id.tv_money)
    TextView tvMoney;
    @BindView(R2.id.tv_type)
    TextView tvType;
    @BindView(R2.id.tv_type_msg)
    TextView tvTypeMsg;
    @BindView(R2.id.tv_status)
    TextView tvStatus;
    @BindView(R2.id.tv_address)
    TextView tvAddress;
    @BindView(R2.id.tv_poundage)
    TextView tvPoundage;
    @BindView(R2.id.view_poundage)
    View viewPoundage;
    @BindView(R2.id.tv_date)
    TextView tvDate;
    @Autowired
    String recordType;
    @Autowired
    String recordId;

    @Override
    public int getLayoutId() {
        return R.layout.wallet_activity_chongti_details;
    }

    @Override
    public ChongtiDetailsPresenter getPresenter() {
        return new ChongtiDetailsPresenter();
    }

    @Override
    public void initView() {
        ARouter.getInstance().inject(this);
        if (recordType.equals(Constans.RECHARGE)) {
            tvPoundage.setVisibility(View.GONE);
            viewPoundage.setVisibility(View.GONE);
            tvType.setText(App.INSTANCE.getString(R.string.wallet_rechargeActivity1));
        } else {
            tvTitle.setText(App.INSTANCE.getString(R.string.wallet_chongtiDetailsActivity2));
        }

    }

    @Override
    public void initData() {
        mPresenter.getChongtiDetails(recordId, recordType);

    }

    public static void start(Context context) {
        Intent intent = new Intent(context, ChongtiDetailsActivity.class);
        context.startActivity(intent);
    }

    public void getChongtiDetailsOK(ChongtiDetailsBean data) {
        if (data == null) {
            return;
        }
        if (data.getRes() == null) {
            return;
        }
        tvMoney.setText(data.getRes().getPrice() + " " + data.getRes().getPname());
        tvPoundage.setText(data.getRes().getTxfee() + " " + data.getRes().getPname());
        tvAddress.setText(data.getRes().getQianbao_url());
        tvStatus.setText(data.getRes().getState());
        tvDate.setText(TimeFormatUtil.formatE(Long.valueOf(data.getRes().getAddtime()) * 1000));
    }
}
